<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/25
 * Time: 10:40
 */

namespace app\index\controller;


use app\index\server\ProductServer;
use app\index\validate\GetListValidate;
use app\index\validate\IDMustBePostiveInt;
use app\index\validate\ProductValidate;

class Product extends Auth
{
    protected $server;

    public function __construct()
    {
        $this->server = new ProductServer();
    }


    public function getProductList()
    {
        // 验证 成功返回 params
        $params = (new GetListValidate())->goCheck();
        // 操作
        $result = $this->server->getList($params);
        // return
        return $result;
    }

    public function addOrUpdate()
    {
        $params = (new ProductValidate())->goCheck();
        $result = $this->server->addOrUpdate($params);
        return $result;
    }


    public function detail($id)
    {
        (new IDMustBePostiveInt())->goCheck();
        $result = $this->server->detail($id);
        return $result;
    }

    public function changeStatus($id)
    {
        (new IDMustBePostiveInt())->goCheck();
        $result = $this->server->changeStatus($id);
        return $result;
    }
    
}